#打印菱形2 多层循环嵌套
for i in range(7):
    for j in range(7 - i - 1):
        print(" ", end="")
        # 打印星号
    for k in range(2 * i + 1):
        print("*", end="")
    print()
for i in range(5, -1, -1):
         # 打印前导空格
    for j in range(7 - i - 1):
        print(" ", end="")
        # 打印星号
    for k in range(2 * i + 1):
         print("*", end="")
    print()
#打印水仙花树
for num in range(100, 1000):
    # 分解三位数
    a = num // 100
    b = (num // 10) % 10
    c = num % 10
    # 检查是否为水仙花数
    if num == a**3 + b**3 + c**3:
        print(num)
#打印100以内的质数
for num in range(2, 101):
    is_prime = True
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            is_prime = False
            break
    if is_prime:
        print(num)
#打印斐波那契数列
n = int(input("请输入斐波那契数列的长度: "))
a, b = 0, 1
for _ in range(n):
    print(a, end=' ')
    a, b = b, a + b
#打印九九乘法表
for i in range(1, 10):
    for j in range(1, i + 1):
        print(f"{j}×{i}={i * j}", end="\t")
    print()
#打印完数
def is_perfect_number(n):
    """判断一个数是否为完全数"""
    if n < 1:
        return False
    sum_of_divisors = 0
    for i in range(1, n):
        if n % i == 0:
            sum_of_divisors += i
    return sum_of_divisors == n
def print_perfect_numbers(start, end):
    """打印指定范围内的所有完全数"""
    perfect_numbers = []
    for num in range(start, end + 1):
        if is_perfect_number(num):
            perfect_numbers.append(num)
    print("完全数列表：", perfect_numbers)

# 示例：打印 1 到 10000 范围内的完全数
print_perfect_numbers(1, 10000)
